package com.feng.extra;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        if(beanName.contains("config")){
            System.out.println("我是BeanPostProcessor 在Bean初始化前后调用 只有 config方法才能通过  "+beanName );
            return bean;
        }
        return null;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        if(beanName.contains("config")){
            System.out.println("我是BeanPostProcessor 在Bean初始化前后调用  只有 config方法才能通过  "+beanName );
            return bean;
        }
        return null;
    }
}
